package com.beerandjesus.sportofkings.handicapper.factory.brisnet.singlefile;

import java.util.ArrayList;
import java.util.List;

import com.beerandjesus.sportofkings.handicapper.model.brisnet.singlefile.KeyTrainerStatistics;
import com.beerandjesus.sportofkings.handicapper.model.brisnet.singlefile.KeyTrainerStatisticsImpl;

public class KeyTrainerStatisticsFactoryImpl extends AbstractObjectFactoryImpl implements KeyTrainerStatisticsFactory {

	private static int FIRST_INDEX = 1337;
	
	/* (non-Javadoc)
	 * @see com.beerandjesus.sportofkings.handicapper.factory.brisnet.singlefile.KeyTrainerStatisticsFactory#getKeyTrainerStatistics(java.lang.String)
	 */
	public List<KeyTrainerStatistics> getKeyTrainerStatistics(String line) {
		String[] values = getValues(line);
		
		return getKeyTrainerStatistics(values);
	}

	public List<KeyTrainerStatistics> getKeyTrainerStatistics(
			String[] values) {
		List<KeyTrainerStatistics> list = new ArrayList<KeyTrainerStatistics>();
		int idx = FIRST_INDEX;
		for (int i = 0; i < 6; i++) {
			 KeyTrainerStatisticsImpl k = new KeyTrainerStatisticsImpl();
			 k.setCategory(val(values, idx++));
			 k.setNumStarts(val(values, idx++));
			 k.setWinPercentage(val(values, idx++));
			 k.setInTheMoneyPercentage(val(values, idx++));
			 k.setTwoDollarROI(val(values, idx++));
			 list.add(k);
		}
		return list;
	}

}
